<template>
	<view class="home">
		<view class="" style="padding-top: 20px;"></view>
		<!--资料详情-->
		<view class="zl_down">
			<view class="zl_c" style="padding-top: 10px;">
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">年龄</text></view>
				<view class="zl_c_f">
					<view class="uni-form-item uni-column">
						<picker @change="agePickerChange" :range="age">
							<label class="">{{age[index1]}}</label>	
						</picker>
					</view>
				</view>	
				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view>
		
			<hr style="height:1px;border:none;border-top:1px dashed #DADCE0;width: 90%;margin: 10px auto;">
			<view class="zl_c" style="padding-top: 10px;">
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">身高</text></view>
				<view class="zl_c_f">
					<view class="uni-form-item uni-column">
						<picker @change="shengaoPickerChange" :range="sg">
							<label class="">{{sg[index2]}}</label>	
						</picker>
					</view>
				</view>
				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view>
			
			<hr style="height:1px;border:none;border-top:1px dashed #DADCE0;width: 90%;margin: 10px auto;">
			<view class="zl_c" style="padding-top: 10px;">
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">体重</text></view>
				<view class="zl_c_f">
					<view class="uni-form-item uni-column">
						<picker @change="tizongPickerChange" :range="tz">
							<label class="">{{tz[index3]}}</label>	
						</picker>
					</view>
				</view>
					
				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view>
			
			<hr style="height:1px;border:none;border-top:1px dashed #DADCE0;width: 90%;margin: 10px auto;">

			<view class="zl_c" style="padding-top: 10px;">
				
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">月收入</text></view>
				<view class="zl_c_f">
					<view class="uni-form-item uni-column">
						<picker @change="shouruPickerChange" :range="sr">
							<label class="">{{sr[index4]}}</label>	
						</picker>
					</view>
				</view>
					
				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view>
			
			<hr style="height:1px;border:none;border-top:1px dashed #DADCE0;width: 90%;margin: 10px auto;">
			<view class="zl_c" style="padding-top: 10px;">
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">学历</text></view>
				<view class="zl_c_f">
					<view class="uni-form-item uni-column">
						<picker @change="xueliPickerChange" :range="xl">
							<label class="">{{xl[index5]}}</label>	
						</picker>
					</view>
				</view>
					
				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view>
			
			<hr style="height:1px;border:none;border-top:1px dashed #DADCE0;width: 90%;margin: 10px auto;">
		
			<view class="zl_c" style="padding-top: 10px;">
				
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">婚姻状况</text></view>
				<view class="zl_c_f">
					<view class="uni-form-item uni-column">
						<picker @change="hunyingPickerChange" :range="hy">
							<label class="">{{hy[index6]}}</label>	
						</picker>
					</view>
				</view>
					
				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view>
			
			<hr style="height:1px;border:none;border-top:1px dashed #DADCE0;width: 90%;margin: 10px auto;">
			
			<!-- <view class="zl_c" style="padding-top: 10px;">
				
				<view class="zl_c_d"><text style="font-size: 14px;color: #4D4D4D;">家乡</text></view>
				<view class="zl_c_f">
					<view class="content" @click="open">
						<label>{{address}}</label>
					</view>
				</view>
				<cityPicker :defaultValue="defaultValue" :mask-close-able="maskCloseAble" @confirm="confirm2" @cancel="cancel" :visible="visible" />

				<view class="zl_c_e">
				  <view class="iconfont icon-bianji"></view>
				</view>
			</view> -->
			
		</view>
		
		<view class="bnt" @click="bnt()" style="padding: 0px 10px;margin-top: 30px;">
			  <button type="default" style="background-color: #F14399;color: #fff;">保存</button>
		</view>
	</view>
</template>


<script>
	import helper from '.../../common/helper.js';  
	import cityPicker from '.../../components/piaoyi-cityPicker/pioayi-cityPicker.vue'
	export default {
		//注册组件
		components: {
		    cityPicker
		},
		data() {
			return {
				seen:false,
                username:{},
				products:{},
				age:['不限','18-25岁','26-30岁','31-35岁','36-40岁','41-45岁','46-50岁','55-60岁'],
				sg:['不限','150-155cm','156-160cm','161-165cm','166-170cm','171-175cm','176-180cm','180|以上'],
				tz:['不限','偏瘦','中等','微胖'],
				sr:['不限','3000-5000元','5000-8000元','1万-2万','2-3万','3万|以上','10万|以上'],
				xl:['不限','初中及以上','高中及以上','大学及以上','研究生及以上'],
				hy:['不限','未婚','离异','丧偶','其他'],
				zy:['不限','运动员','教师','教授','学生','董事长','总经理','副总/总监','部门经理','中层管理','企业家','个体老板','高级干部','公务员','律师','医生','护士','专家学者','工程师','设计师','艺术家','演员','模特','离/退休','技术员','服务员','普通员工','自由职业','无业','程序员'],
				index1:0,
				index2:0,
				index3:0,
				index4:0,
				index5:0,
				index6:0,
				visible: false,
				maskCloseAble: true,
				str: '',
				defaultValue: '',
				address:''
			}
		},
		onLoad(options) {
		  this.id=options.id
		  this.xiangqing()
		},
		methods: {
			async out(){
				setTimeout(() => {
					uni.clearStorage()
					this.$router.go(0)
					uni.navigateTo({
					    url: '/pages/login/login'
					});
				}, 400)
			},
			open () {
			    this.visible = true
			},
			confirm2 (val) {

			    this.str = val
			    this.visible = false
				this.address=val.name
			},
			cancel () {
			    this.visible = false
			},
			//年龄
			agePickerChange: function(e) {		
				this.index1 = e.target.value			
			},
			//身高
			shengaoPickerChange: function(e) {		
				this.index2 = e.target.value			
			},
			//体重
			tizongPickerChange: function(e) {		
				this.index3 = e.target.value			
			},
			//收入
			shouruPickerChange: function(e) {		
				this.index4 = e.target.value			
			},
			//学历
			xueliPickerChange: function(e) {		
				this.index5 = e.target.value			
			},
			//婚姻情况
			hunyingPickerChange: function(e) {		
				this.index6 = e.target.value			
			},
			//保存
			async bnt(){
				var index1=this.index1;
				var index2=this.index2;
				var index3=this.index3;
				var index4=this.index4;
				var index5=this.index5;
				var index6=this.index6;
				var index7=this.index7;
		
				const res = await this.$myRuquest({
					url:'index/dsnv.activities/sx_screen',
					method:'post',
					data:{
						"uid":this.id,
						"age":this.age[index1],//出生日期
						"height":this.sg[index2],//身高
			            "weight":this.tz[index3],//体重
						"monthly_income":this.sr[index4],//收入
						"education":this.xl[index5],//学历
						"hunyin_status":this.hy[index6],//婚姻状态
						"occupation":this.zy[index7],//职业
						"hometown":this.address,//故乡
					},
					
				})

				if(res.data.code ==200){
					setTimeout(() => {
						uni.showToast({
							title:"保存成功",
							duration: 3000,
							icon: 'none'
						})	
					}, 400)
				
				}else{
					uni.showToast({
						title:"保存失败",
						duration: 3000,
						icon: 'none'
					})			
				}
			},
            //详情
			async xiangqing(){
			  
				const res = await this.$myRuquest({
					url:'index/dsnv.activities/sx_edit',
					method:'post',
					data:{
						"id":this.id,
					},
				})

				if(res.data.code ==200){

						this.address = res.data.date.hometown

					    this.age =[res.data.date.age,'18-25岁','26-30岁','31-35岁','36-40岁','41-45岁','46-50岁','55-60岁'], 
		
					    this.sg=[res.data.date.height,'150cm','151cm','152cm','153cm','154cm','155cm','156cm','157cm','158cm','159cm','160cm','161cm','162cm','163cm','164cm','165cm','166cm','167cm','168cm','169cm','170cm','171cm','172cm','173cm','174cm','175cm','176cm','177cm','178cm','179cm','180cm','181cm','182cm','183cm','185cm','186cm','187cm','188cm','189cm','190cm','190cm以上'];
					
						this.tz=[res.data.date.weight,'38kg','39kg','40kg','41kg','42kg','43kg','44kg','45kg','46kg','47kg','48kg','49kg','50kg','51kg','52kg','53kg','54kg','55kg','56kg','57kg','58kg','59kg','60kg','61kg','62kg','63kg','64kg','65kg','66kg','67kg','68kg','69kg','70kg','71kg','72kg','73kg','74kg','75kg','76kg','77kg','78kg','79kg','80kg','81kg','82kg','83kg','84kg','85kg','86kg','87kg','88kg','89kg',,'90kg','91kg','92kg','93kg','94kg','95kg','96kg','97kg','98kg','99kg','100kg','100kg以上'];
				

				
						this.sr=[res.data.date.monthly_income,'3000-5000','5000-8000','1万-2万','2-3万','3万|以上'];
				
						this.xl=[res.data.date.education,'初中|以上','高中|以上','大学|以上','研究生|以上'];

						this.zy=[res.data.date.occupation,'运动员','教师','教授','学生','董事长','总经理','副总/总监','部门经理','中层管理','企业家','个体老板','高级干部','公务员','律师','医生','护士','专家学者','工程师','设计师','艺术家','演员','模特','离/退休','技术员','服务员','普通员工','自由职业','无业','程序员'];

						this.hy=[res.data.date.hunyin_status,'未婚','离异','丧偶','其他'];

			}
		}	
		}
	}
</script>

<style lang="scss">

	.home{
		height: 850px;
		background-color: #F6F6F6;

		
		.middle{
			background-color: #fff;
			margin: 0 10px;
			display: flex;
			height: 90px;
			border-radius: 10px;
			text-align: center;
			.middle_c{
				margin-top: 10px;
				width: 33%;
			}
			
		}
		.zl_down{
			background-color: #fff;
		
			margin: 0 10px;
			height: 420px;
			border-radius: 10px;
			.zl_c{
				display: flex;
				padding-left: 20px;
				.zl_c_d{
					margin-top: 6px;
					margin-left: 5px;
					width: 60%;
				}
				.zl_c_f{
					text{
						float: right;
					}
					width: 30%;
					margin-top: 5px;
				}
				.zl_c_e{
					margin-left: 3px;
					padding-right: 20px;
					margin-top: 8px;
				}
			}
			
			
		}
		
		
}
</style>
